package com.wen.common.dto;

import com.wen.common.annotation.Sensitive;
import com.wen.common.enums.SensitiveStrategy;
import com.wen.common.pojo.system.User;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;

@Data
public class UserDTO {

    @NotNull(message = "主标识不能为空")
    private Long id;
    /**
     * 用户名
     */
    @NotNull(message = "用户名不能为空")
    private String userName;
    /**
     * 密码
     */
    @NotNull(message = "密码不能为空")
    private String password;
    /**
     * 昵称
     */
    private String nickName;
    /**
     * 年龄
     */
    private Integer age;
    /**
     * 性别： 1男 0女 2未知
     */
    private String sex;
    /**
     * 地址；脱敏处理
     */
    @Sensitive(strategy = SensitiveStrategy.ADDRESS)
    private String address;
    /**
     * 头像地址
     */
    private String avatar;
    /**
     * 邮箱
     */
    @Sensitive(strategy = SensitiveStrategy.EMAIL)
    private String email;
    /**
     * 电话号码
     */
    @Sensitive(strategy = SensitiveStrategy.PHONE)
    private String phoneNumber;
    /**
     * 余额
     **/
    private BigDecimal money;

    /**
     * 状态： 0锁定 1有效
     */
    private String status;

    private List<Long> roles;

    private String token;

    public UserDTO() {
    }

    // 封装dto
    public UserDTO(User user) {
        this.id = user.getId();
        this.userName = user.getUserName();
        this.password = user.getPassword();
        this.nickName = user.getNickName();
        this.age = user.getAge();
        this.sex = user.getSex();
        this.address = user.getAddress();
        this.avatar = user.getAvatar();
        this.money = user.getMoney();
        this.email = user.getEmail();
        this.phoneNumber = user.getPhoneNumber();
        this.status = user.getStatus();
        this.token = user.getToken();

//      this.roles =
//      this.token =
    }

}
